// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/base/api/DashboardManageApi'

import InfoClass from '@api/base/model/AlarmChartReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async getInfo(param, TIP = `查询${CORE.MAP.ALARM}趋势`) {
    const DTO = CORE.grpcDTO(InfoClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryAlarmChart', DTO)
    return CORE.isEmpty(resp.chart) ? {} : resp.chart[0]
  },
  transInfo(obj, { state: { info: { xData } } }) {
    const yList = ((obj.data || [])[0] || {}).yData || []
    const dataList = xData.map((_, i) => yList[i] || 0)
    return { dataList }
  },
}
